package com.neuedu.corejava.ch9;

public class StringClass {

	public static void main(String[] args) {
		String string = new String("abc");
		// java的字符串对象是不可以修改的，每次修改的字符串都会分配新的内存空间
		string = new String("zxcvbnm");
		// string类的修改性能很低
		string = new String("feydegueogogv");
		
		
		// 带缓冲的字符串类 --->StringBuffer线程安全,StringBuilder线程不安全
		//StringBuffer buffer = new StringBuffer();
		StringBuilder buffer = new StringBuilder();
		buffer.append(false);
		buffer.append("hello");
		buffer.insert(5, "abcdef");

		int cap = buffer.capacity();// 字符串缓冲容量
		int length = buffer.length();
			
		System.out.println(cap +" "+length);
		System.out.println(buffer);
		
		buffer.insert(0, "aa");
		
		buffer.delete(0, 12);
		buffer.trimToSize();
		
		cap = buffer.capacity();// 字符串缓冲容量
		length = buffer.length();
		
		System.out.println(cap +" "+length);
		System.out.println(buffer);
		
		//buffer.replace(0, buffer.length(), "a");
		buffer.reverse();
		System.out.println(buffer);
		
		
		
	}

}
